package com.lenovo.vod.player.setting.util;

public class NumberUtils {

	public static String intToCnNum(int num ,String cnNum,String cnW,char mW,char mY,char mL) {
		StringBuilder sb = new StringBuilder();
		final String CN_NUM = cnNum;
		final String CN_W = cnW;
		int n = num;
		for (int i = 0; n > 0; i++) {
			int g = n % 10;
			if ((i >= 1) && (i <= 3)) {
				if (g != 0) {
					sb.insert(0, CN_W.charAt(i - 1));
				}
			} else if (i == 4) {
				sb.insert(0, mW);
			} else if ((i >= 5) && (i <= 7)) {
				if (g != 0) {
					sb.insert(0, CN_W.charAt(i - 4 - 1));
				}
			} else if (i == 8) {
				sb.insert(0, mY);
			} else if ((i >= 9) && (i <= 10)) {
				if (g != 0) {
					sb.insert(0, CN_W.charAt(i - 8 - 1));
				}
			}
			if ((g != 0) || ((i > 0) && (sb.charAt(0) != mL))) {
				sb.insert(0, CN_NUM.charAt(g));
			}
			n = n / 10;
		}
		if ((sb.length() > 1) && (sb.charAt(sb.length() - 1) == mL)) {
			sb.setLength(sb.length() - 1);
		}
		return sb.toString();
	}

}
